from django.db import models

# Create your models here.
from users.models import User


class Activity(models.Model):
    """活动"""

    name = models.CharField(max_length=20, verbose_name='活动名称')
    published_time = models.DateTimeField(verbose_name='举办时间')
    sign_up_start = models.DateTimeField(verbose_name='报名开始时间')
    sign_up_end = models.DateTimeField(verbose_name='报名结束时间')
    image_url = models.ImageField(verbose_name='图片链接地址')
    host_place = models.CharField(max_length=20, verbose_name='举办地点')
    host_city = models.CharField(max_length=10, verbose_name='举办城市')
    introduce = models.TextField(verbose_name='大会介绍')
    abstract = models.TextField(verbose_name='议题简介')
    organizers = models.CharField(max_length=10, verbose_name='主办方')
    website_url = models.CharField(max_length=20, verbose_name='官方链接')
    release_time = models.DateTimeField(verbose_name="活动发布时间")
    on_deleted = models.BooleanField(verbose_name="逻辑删除")
    is_apply = models.BooleanField(verbose_name='报名状态', default=False)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'tb_activities'
        verbose_name = '活动信息表'
        verbose_name_plural = verbose_name


class SignUp(models.Model):
    """活动报名表"""
    user = models.ForeignKey(User, verbose_name='用户')  # 外键
    activity = models.ForeignKey(Activity, verbose_name='活动')  # 外键
    sign_up_time = models.DateTimeField(auto_now_add=True, verbose_name='报名时间')

    class Meta:
        db_table = 'tb_sign_up'
        verbose_name = '活动报名表'
        verbose_name_plural = verbose_name
